//
//  Auction_OfferPrice_View_WX.m
//  ZITHER
//
//  Created by weixin on 2019/5/30.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Auction_OfferPrice_View_WX.h"

@interface Auction_OfferPrice_View_WX ()<QMUITextFieldDelegate>

@property (nonatomic,strong)QMUITextField *codeFt;

@end

@implementation Auction_OfferPrice_View_WX

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addToKeyWindow];
    }
    return self;
}

-(void)show{
    [super show];
    [self addSubview:self.backView];
}

-(void)setState:(OfferPriceState)State{
    _State = State;
    if (State == OfferPriceNormal) {
        self.codeFt.hidden = YES;
        self.titleOfferLab.hidden = NO;
    }else{
        self.codeFt.hidden = NO;
        self.titleOfferLab.hidden = YES;
    }
}


-(BaseView *)backView{
    if (!_backView) {
        _backView = [[BaseView alloc]initWithFrame:CGRectMake(0, kScreenH -kScreenW, kScreenW, kScreenH-kScreenW)];
        _backView.backgroundColor =  HexColor(0xf5f5f5);
        
        [_backView setCornerRadiusWithRadius:15 isMasks:YES];
        [self addSubview:_backView];
        [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
            make.height.mas_equalTo(kScreenH-kScreenW);
        }];
        [self setUI];
    }
    return _backView;
}

-(void)setUI{
    

    /* MARK: ================= 上面灰色手表信息部分 =================*/

    [self.backViewTop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self).offset(0);
        make.top.equalTo(self.backView).offset(0);
        make.height.mas_equalTo(kScreenW/374.0*141);
    }];
    [self.watchPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.backViewTop).offset(14);
        make.top.equalTo(self.backViewTop).offset(20);
        make.height.width.mas_equalTo(100);
    }];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.watchPic.mas_right).offset(7);
        make.right.equalTo(self.backViewTop).offset(-18);
        make.top.equalTo(self.backViewTop).offset(25);
    }];
    [self.specialSaleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.watchPic.mas_right).offset(7);
        make.bottom.equalTo(self.watchPic.mas_bottom).offset(-20);
    }];
    [self.PriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.specialSaleLab.mas_right).offset(7);
        make.centerY.equalTo(self.specialSaleLab).offset(0);
    }];
    
    
    
    //titleOfferTitleLab;
    //locationBtn;
    //titleOfferLLab;//报价
    //done;//报价
    /* MARK: ================= 下面白色报价部分 =================*/
    
    [self.backViewBottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self).offset(0);
        make.top.equalTo(self.backViewTop.mas_bottom).offset(0);
        make.bottom.equalTo(self).offset(0);
    }];
    [self.titleOfferTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(14);
        make.top.equalTo(self.backViewTop.mas_bottom).offset(20);
    }];
    
    [self.locationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleOfferTitleLab).offset(0);
        make.right.equalTo(self.backViewTop).offset(-20);
    }];
    
    [self.titleOfferLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleOfferTitleLab.mas_bottom).offset(10);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.height.width.mas_equalTo((kScreenW-30)/345.0*45);
    }];
    
    [self.codeFt mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleOfferTitleLab.mas_bottom).offset(10);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.height.width.mas_equalTo((kScreenW-30)/345.0*45);
    }];
    
    [self.done mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.titleOfferLab).offset(0);
        make.top.equalTo(self.titleOfferLab.mas_bottom).offset(30);
        make.left.equalTo(self).offset(100);
        make.right.equalTo(self).offset(-100);
        make.height.mas_equalTo(40);
    }];

}

//backViewTop;
//watchPic;
//titleLab;
//specialSaleLab;
//PriceLab;




/* MARK: ================= 上面灰色手表信息部分 =================*/
-(BaseView *)backViewTop{
    if (!_backViewTop) {
        _backViewTop = [[BaseView alloc]initWithFrame:CGRectMake(0, kScreenH -400, kScreenW, kScreenH-400)];
        _backViewTop.backgroundColor = HexColor(0xf5f5f5);
        [_backViewTop setCornerRadiusWithRadius:15 isMasks:YES];
        [self.backView addSubview:_backViewTop];
    }
    return _backViewTop;
}

-(BaseImageV *)watchPic{
    if (!_watchPic) {
        _watchPic= [BaseImageV initCustom:CGRectZero contentMode:2];
        _watchPic.image = [UIImage imageNamed:@"位置图标"];
        _watchPic.backgroundColor = [UIColor grayColor];
        [_watchPic setCornerRadiusWithRadius:6 isMasks:YES];
        [self.backViewTop addSubview:_watchPic];
    }
    return _watchPic;
}

-(BaseLab *)titleLab{
    if (!_titleLab) {
        _titleLab = [BaseLab initCustomLab:@"介绍介绍介绍介绍介绍介绍介绍介绍介绍介绍介绍介绍" color:HexColor(0x333333) font:[UIFont fontWithName:@"PingFang-SC-Regular" size:15]];
        _titleLab.backgroundColor = [UIColor clearColor];
        _titleLab.numberOfLines = 2;
        [self.backViewTop addSubview:_titleLab];
    }
    return _titleLab;
}

-(BaseLab *)specialSaleLab{
    if (!_specialSaleLab) {
        _specialSaleLab = [BaseLab initCustomLab:@"特卖价格" color:HexColor(0xff6f6f) font:[UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
        _specialSaleLab.backgroundColor = [UIColor clearColor];
        [self.backViewTop addSubview:_specialSaleLab];
    }
    return _specialSaleLab;
}

-(BaseLab *)PriceLab{
    if (!_PriceLab) {
        _PriceLab = [BaseLab initCustomLab:@"531,111" color:HexColor(0xff6f6f) font:[UIFont fontWithName:@"PingFangSC-Semibold" size:20]];
        _PriceLab.backgroundColor = [UIColor clearColor];
        [self.backViewTop addSubview:_PriceLab];
    
    }
    return _PriceLab;
}

/* MARK: ================= 下面白色报价部分 =================*/
-(BaseView *)backViewBottom{
    if (!_backViewBottom) {
        _backViewBottom = [[BaseView alloc]initWithFrame:CGRectMake(0, kScreenH -400, kScreenW, kScreenH-400)];
        _backViewBottom.backgroundColor = [UIColor whiteColor];
//        [_backViewBottom setCornerRadiusWithRadius:15 isMasks:YES];
        [self.backView addSubview:_backViewBottom];
    }
    return _backViewBottom;
}

-(BaseLab *)titleOfferTitleLab{
    if (!_titleOfferTitleLab) {
        _titleOfferTitleLab = [BaseLab initCustomLab:@"报价" color:HexColor(0x333333) font:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
        _titleOfferTitleLab.backgroundColor = [UIColor clearColor];
        [self.backViewBottom addSubview:_titleOfferTitleLab];
    }
    return _titleOfferTitleLab;
}

- (BaseBtn *)locationBtn{
    if (!_locationBtn) {
        _locationBtn = [BaseBtn initCustomBtnImageAndTitles:@[@"商户地址"] images:@[@"未知图标"] color:@[baseColorTheme]];
        _locationBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14];
        [self.backViewBottom addSubview:_locationBtn];
    }
    return _locationBtn;
}

-(BaseLab *)titleOfferLab{
    if (!_titleOfferLab) {
        _titleOfferLab = [BaseLab initCustomLab:@"   ¥531,111" color:HexColor(0xff6f6f) font:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
        [_titleOfferLab setCornerRadiusWithRadius:6 isMasks:YES];
        _titleOfferLab.backgroundColor = HexColor(0xf5f5f5);
        [self.backViewBottom addSubview:_titleOfferLab];
        _titleOfferLab.hidden = YES;
    }
    return _titleOfferLab;
}

- (BaseBtn *)done{
    if (!_done) {
        _done = [BaseBtn initCustomBtnTitlestype:@[@"确定"] color:@[[UIColor whiteColor]]];
        _done.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15];
        _done.backgroundColor =  baseColorTheme;
        [_done setCornerRadiusWithRadius:6 isMasks:YES];
        [self.backViewBottom addSubview:_done];
    }
    return _done;
}


//titleOfferTitleLab;
//locationBtn;
//titleOfferLLab;//报价
//done;//报价

-(QMUITextField *)codeFt{
    if (!_codeFt) {
        _codeFt = [[QMUITextField alloc]initWithFrame:CGRectMake(0, 100, 150, 50)];
        _codeFt.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:20];
        _codeFt.delegate = self;
        _codeFt.placeholderColor = [UIColor whiteColor]; // 自定义 placeholder 的颜色
        _codeFt.returnKeyType = UIReturnKeyDone;
        _codeFt.enablesReturnKeyAutomatically = YES;
        _codeFt.tintColor = HexColor(0xff6f6f);
        _codeFt.backgroundColor = HexColor(0xf5f5f5);
        [_codeFt setCornerRadiusWithRadius:6 isMasks:YES];
        _codeFt.textColor = HexColor(0xff6f6f);
        
        // 限制可输入的字符长度
        _codeFt.maximumTextLength = 9;
        
        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
        NSAttributedString *attri = [[NSAttributedString alloc] initWithString:@"¥请输入" attributes:@{NSForegroundColorAttributeName: HexColor(0x999999),NSFontAttributeName:[UIFont fontWithName:@"PingFang-SC-Regular" size:15], NSParagraphStyleAttributeName:style}];
        _codeFt.attributedPlaceholder = attri;
        [self.backView addSubview:_codeFt];

        
    }
    return _codeFt;
}
@end
